package demo.dubbo.consumer;

import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import com.alibaba.fastjson.JSONObject;

import demo.design.patterns.structural.FacadeDemo;

public class DubboClientDemo {

    private static Logger logger = LoggerFactory.getLogger(DubboClientDemo.class);

    static {
        System.setProperty("dubbo.application.logger", "slf4j");

    }

    public static void main(String[] args) throws Exception {
        demoBonePutData();
        com.alibaba.dubbo.common.utils.NetUtils a = null;
    }

    @Test
    public void boneGetData() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                "classpath:demo/dubbo/consumer/resources/consumer-demo.xml");
        context.start();
        FacadeDemo featureFacade = (FacadeDemo) context.getBean("featureFacade");
        String pojo = featureFacade.sayHello("Stan");
        if (pojo != null) {
            logger.info("{}", JSONObject.toJSONString(pojo));
        }
        context.close();
    }

    static void demoBonePutData() {
        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(
                "classpath:demo/dubbo/client/resources/consumer-demo.xml");
        context.start();
        ThreadPoolExecutor executor = new ThreadPoolExecutor(8, 8, 0L, TimeUnit.MILLISECONDS,
                new LinkedBlockingQueue<Runnable>());
        for (int i = 32; i < 64; i++) {
            String zipData = "H4sIAAAAAAAAAK1dS49muW39L732QpQokZp11lllZ3jhGF4Y8CMw4oUR5L/nnFsdY+oj7+WnQnXPYAZT6DN68HH4EO9v/+fHH37/5z//2z/+/vv//tPf/vrjl/ab6z/8+z/+8p9//PuPX360bnObiC358fGj//jTX/744xeZulZT87lG//mDf/4XftD/9zevmNMD6tjSV7O9d0Cde4zlTVqB6n4E2n20odVSzxbabfu0ClP6PEOdw1a3713pHPiXXR3pK+aU4dKcAhBBfc8muuevQaVeqIzhNucYeyWYDmnbun6NOd/CbMOb4a+Iad38jc2/Yu7Zx1w+EsC2Td3PFzkhLjp8e8Rca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ri+JYyKku62m9pEGdr784PHhyf5DMmopRyDt4hpi95+fhUdphx4gq/hSNzjxz1+kpa+Uwm0vRH0GtwW9mGHGck39w7KNDrZLm3UprwKuy/1vA+hJiwA142law4rm44mzl9WrbSNtW3nXOWbexJnRZS5MRUDqj4AqZzHGWPr2MuTENEccwrH0+U3ySSclpZuvfZ2W2cYXbTeV4Cfl6nsJBRYcYPGd1Ip7DRpJ5xmpjNMVd8aaLOOuBr0uTNmQZMBEZAFlhgOeoux/fpuXJSsr7x6aqT6+YYi8nvT33jdTv8xcQVlZX0WLVLrxt4y9cs/UXoOW+GK+VM7fgURNkzt17HBL/TfP3Qdw7QAcZaf17uIIACJsf9qh97S37ORTtMUqQJPiBjnMh5vPln0KuV4Hga0JPID1V+wvPcwj0c6NDOeZyf1vnONKACU/mFnEMDUmE2ffn+2duDVmLaTY3THdfLHKB3vtcFNcFiQH5DCejChE0alaFL8rj3O7e1yeHX6Qy1AhP8fZcEMXTiPImncYSVf+G999VJYM6hsAlon92t7HnIcsNPmKJeZlw1DDmASQZNiozTOJ4NjqNMwkQee4t4ffCznMMQbv0ej8V+qR4BJW1S8TEAQipl+5F8Zfri9a3hEcdZKJ+LrzfmzISupgJ0qa5yqr7HlmieZMRr/DxDKzvhI5e5g7NraHkBF+bL5OQAcMtHf61F/u7/AAJnHC3EfAAA";
            FacadeDemo featureFacade = (FacadeDemo) context.getBean("dataUploadFacade");
            for (int j = 0; j < 10; j++) {
                long userId = i;
                executor.submit(() -> {
                    String result = featureFacade.sayHello("Stan");
                    logger.info("result:{}", result);
                });
            }
        }
        try {
            Thread.sleep(8000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        executor.shutdown();
        context.close();
    }
}
